﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Disk
{
    class FileDown
    {
        public static bool Down(string Filename)
        {
            //选择地址
            string foldPath;
            FolderBrowserDialog flbDlg = new FolderBrowserDialog();
            flbDlg.ShowNewFolderButton = true;
            flbDlg.Description = "请选择文件路径";
            if (flbDlg.ShowDialog() == DialogResult.OK)
            {
                foldPath = flbDlg.SelectedPath;
            SaveFileDialog sfd = new SaveFileDialog();
            //下载ation地址
            string remoteUri = $"http://localhost:55442/api/Upload?name={Filename}";
            //本地存储地址
            string fileName = string.Format($"{foldPath}\\{Filename}"), myStringWebResource = null;
            WebClient myWebClient = new WebClient();
            myStringWebResource = remoteUri;
            myWebClient.DownloadFile(myStringWebResource, fileName);
            return true;
            }
            else
            {
                return false;
            }
         
        }
    }
}
